package org.hhchat.leetcode.dfs;

import org.hhchat.leetcode.dataStruct.Employee;

import java.util.List;

/**
 * Created this one by HMH on 2017/10/3.
 */
public class code690_easy {

    class Solution {
        public int getImportance(List<Employee> employees, int id) {
            dfs(employees, id-1);
            return sum;
        }

        int sum = 0;


        public void dfs(List<Employee> employees, int index) {
            Employee cur = employees.get(index-1);
            for (int c : cur.subordinates) {
                dfs(employees, c);
            }
            sum += cur.importance;
        }
    }

    public static void main(String[] args){

    }

}
